﻿/*
 * common.h
 *
 *  Created on: 2012-7-24
 *      Author: Fifi Lyu
 *        Desc: 平台无关，通用函数库，使用异常处理错误
 */

#ifndef INCLUDE_ZPSOE_COMMON_H_
#define INCLUDE_ZPSOE_COMMON_H_

#include "zpsoe/config_compiler.h"
#include "zpsoe/config_platform.h"
#include "zpsoe/ztypes.h"
#include <cmath>

namespace zpsoe {

static const string LINUX_SEPARATOR("/");
static const char LINUX_SEPARATOR_CHAR = '/';
static const string WINDOWS_SEPARATOR("\\");
static const char WINDOWS_SEPARATOR_CHAR = '\\';

#ifdef PLATFORM_WIN32
    #define popen _popen
    #define pclose _pclose
    static const string OS_SEPARATOR = WINDOWS_SEPARATOR;
    static const char OS_SEPARATOR_CHAR = WINDOWS_SEPARATOR_CHAR;
    static const string TO_NULL(" >nul 2>&1");
    static const string OS_LINE_FEED("\r\n");
#else
    static const string OS_SEPARATOR = LINUX_SEPARATOR;
    static const char OS_SEPARATOR_CHAR = LINUX_SEPARATOR_CHAR;
    static const string TO_NULL(" >/dev/null 2>&1");
    static const string OS_LINE_FEED("\n");
#endif

} /* namespace zpsoe */

#endif  // INCLUDE_ZPSOE_COMMON_H_
